exp07.RunLayer_01 = cc.Layer.extend({
	arr:null,
	scene:null,
	clock:null,
	ctor:function (parent) {
		this._super();
		cc.director.setProjection(cc.Director.PROJECTION_2D);
		cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 1;
		this.scene = parent;
		this.scene.addChild(this, 10);
		gg.main = this;
		this.init();
	},
	init:function () {
		this.callNext = cc.callFunc(function(){
			gg.flow.next();
		}, this);
		this.callKill = cc.callFunc(function(p){
			var seq = cc.sequence(cc.fadeOut(0.5),cc.callFunc(function(){
				p.removeFromParent(true);	
			}, this));
			p.runAction(seq);
		}, this); 

		this.callNext.retain();
		this.callKill.retain();
		//时钟
		this.clock = new Clock(this);
		// 物品库
		this.lib = new Lib(this);
		this.lib.loadBg([
		                 {tag:TAG_LIB_CONICAL},
		                 {tag:TAG_LIB_AMPULLA},
		                 {tag:TAG_LIB_COLD,checkright:true},
		                 {tag:TAG_LIB_TESTTUBE},
		                 {tag:TAG_LIB_LAMP},
		                 {tag:TAG_LIB_WATER},
		                 {tag:TAG_LIB_INOCULATOR,checkright:true},
		                 {tag:TAG_LIB_ROD},
		                 {tag:TAG_LIB_MATCH},
		                 {tag:TAG_LIB_HOT,checkright:true},
		                 ]);
		//实战中，默认出lib，得分字不出
		ll.tip.scoreLabel.setVisible(false);
		//左边烧杯（冷水）
		this.loadColdWater();
		//右边烧杯（热水）
		this.loadHotWater();
		//注射器
		this.injector = new Injector(this);
	},
	loadColdWater:function(){
		//烧杯1号（左边）--冷水body
		var cold_body = new Button(this, 21, TAG_COLD_BODY, "#run/beaker_body.png",this.callback);
		cold_body.setPosition(cc.p(440,280));
		cold_body.setScale(0.5);
		cold_body.setVisible(false);
		//烧杯1号（左边）--冷水part
		var cold_part = new Button(this, 18, TAG_COLD_PART, "#run/beaker_part.png",this.callback);
		cold_part.setPosition(cc.p(440,280));
		cold_part.setScale(0.5);
		cold_part.setVisible(false);
		//冷水--文字
		var cold_word = new cc.LabelTTF("冷\n水",gg.fontName,gg.fontSize);
		cold_body.addChild(cold_word);
		cold_word.setPosition(cc.p(-10,93));
		cold_word.setScale(2);
	},
	loadHotWater:function(){
		//烧杯2号（右边）--热水body
		var hot_body = new Button(this, 21, TAG_HOT_BODY, "#run/beaker_body.png",this.callback);
		hot_body.setPosition(cc.p(870,280));
		hot_body.setScale(0.5);
		hot_body.setVisible(false);
		//烧杯2号（右边）--热水part
		var hot_part = new Button(this, 19, TAG_HOT_PART, "#run/beaker_part.png",this.callback);
		hot_part.setPosition(cc.p(870,280));
		hot_part.setScale(0.5);
		hot_part.setVisible(false);
		//热水--文字
		var hot_word = new cc.LabelTTF("热\n水",gg.fontName,gg.fontSize);
		hot_body.addChild(hot_word);
		hot_word.setPosition(cc.p(-10,93));
		hot_word.setScale(2);
		//热水--热气
		var hot_wuqi = new cc.Sprite("#run/zhengqi.png");
		hot_part.addChild(hot_wuqi);
		hot_wuqi.setPosition(cc.p(159,493));
		hot_wuqi.setScale(2);
	},
	checkVisible:function(next){
		//是否可见
		var checkVisible = [];
		var cold_body = this.getChildByTag(TAG_COLD_BODY);
		var cold_part = this.getChildByTag(TAG_COLD_PART);
		var hot_body = this.getChildByTag(TAG_HOT_BODY);
		var hot_part = this.getChildByTag(TAG_HOT_PART);
		var injector = ll.run.injector;
		var show = ll.run.getChildByTag(TAG_SHOW);
		checkVisible.push(cold_body, cold_part, hot_body, hot_part, injector,
				 show);

		for(var i in checkVisible){
			if(checkVisible[i] !== null){				
				checkVisible[i].setVisible(next);				
			}			
		}
	},
	loadInLib:function(obj, pos, tarPos,delay){
		obj.setPosition(pos);
		if(delay == null){
			delay = 1;
		}
		var ber = $.bezier(pos, tarPos, delay);
		var seq = cc.sequence(ber, this.callNext);
		obj.runAction(seq);
	},
	kill:function(obj){
		var fade = cc.fadeTo(0.5,0);
		var func = cc.callfunc(function(){
			obj.removeFromParent(true);
		},this);
		var seq = cc.sequence(fade,func);
		obj.runAction(seq)
	},
	flowNext:function(){
		gg.flow.next();
	},
	onExit:function(){
		this._super();
		this.callNext.release();
		this.callKill.release();
	}
});